package com.chixing.service.impl;

import com.chixing.entity.Employee;
import com.chixing.mapper.EmployeeMapper;
import com.chixing.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public void updateBalance(Employee fromEmp, Employee toEmp) {
        fromEmp.setEmpSalary(fromEmp.getEmpSalary() -100);
        toEmp.setEmpSalary(toEmp.getEmpSalary() + 100);
        employeeMapper.updateBalance(fromEmp); // update emp set salary ....
//        int a = 10/0;
        employeeMapper.updateBalance(toEmp); // update emp set salary ....
    }

    @Override
    public Employee getByNo(Integer empno) {
        return employeeMapper.selectById(empno);
    }
}
